
const { sequelize, DataTypes } = require('../utill/getSequelize')

//用户表
const T_user = sequelize.define('T_user', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true,
    },

    // user_uuid:{
    //     type:DataTypes.STRING,
    //     allowNull:false
    // },

    user_name: {
        type: DataTypes.STRING,
        allowNull: false,
    },

    password: {
        type: DataTypes.STRING,
        allowNull: false,
    },

    real_name: {
        type: DataTypes.STRING,
        allowNull: false,
    },

    role: {
        //1代表学生，2代表老师，3代表管理员
        type: DataTypes.STRING,
        allowNull: false,
    },
    
    phone_num: {
        type: DataTypes.STRING,
        allowNull: false,
    },

    status: {

        //1代表启动，2代表禁用
        type: DataTypes.INTEGER,
        allowNull: true,
    },

    image_path: {
        type: DataTypes.STRING,
        allowNull: true,
        defaultValue: "",
    }

});


//同步模型和数据库表
(async () => {
    try {
        await sequelize.sync({ force: false });
        console.log('All models were synchronized successfully.');
    } catch (error) {
        console.log(error);
    }

})();

//提供出去
module.exports = { T_user };